<?php
?>

<div class="modal-body" id="auth_content">
    <div class="form-horizontal">
        <div class="form-group">
            <label class="col-lg-3 col-sm-3 control-label">用户：</label>
            <div class="col-lg-3">
                <label class="form-control"><?= $item['name'] ?></label>
            </div>
            <label class="col-lg-3 col-sm-3 control-label">手机号：</label>
            <div class="col-lg-3">
                <label class="form-control"><?= $item['phone'] ?></label>
            </div>
        </div>

        <div class="form-group">
            <label class="col-lg-3 col-sm-3 control-label">提现类型：</label>
            <div class="col-lg-3">
                <label class="form-control">
                    <?php
                    switch ($item['type']) {
                        case 1:
                            echo '微信';
                            break;
                        case 2:
                            echo '支付宝';
                            break;
                    }
                    ?>
                </label>
            </div>
            <label class="col-lg-3 col-sm-3 control-label">提现账号：</label>
            <div class="col-lg-3">
                <label class="form-control"><?= $item['account'] ?></label>
            </div>
        </div>

        <div class="form-group">
            <label class="col-lg-3 col-sm-3 control-label">提现金额：</label>
            <div class="col-lg-3">
                <label class="form-control"><?= $item['amount'] ?></label>
            </div>
            <label class="col-lg-3 col-sm-3 control-label">用户账户总额：</label>
            <div class="col-lg-3">
                <label class="form-control"><?= $item['user_account'] ?></label>
            </div>
        </div>

        <div class="form-group">
            <label class="col-lg-3 col-sm-3 control-label">状态：</label>
            <div class="col-lg-3">
                <label class="form-control">
                    <?php
                    switch ($item['status']) {
                        case 0:
                            echo '待审核';
                            break;
                        case 1:
                            echo '提现成功';
                            break;
                        case 2:
                            echo '提现失败';
                            break;
                    }
                    ?>
                </label>
            </div>
        </div>

        <div class="form-group">
            <label class="col-lg-3 col-sm-3 control-label">申请时间：</label>
            <div class="col-lg-3">
                <label class="form-control"><?= $item['create_datetime'] ?></label>
            </div>
            <label class="col-lg-3 col-sm-3 control-label">审核时间：</label>
            <div class="col-lg-3">
                <label class="form-control"><?= $item['modify_datetime'] ?></label>
            </div>
        </div>

        <div class="form-group">
            <label class="col-lg-3 col-sm-3 control-label">备注：</label>
            <div class="col-lg-9">
                <textarea class="form-control" id="authRemark"><?= $item['remark'] ?></textarea>
            </div>
        </div>
    </div>
</div>
<div class="modal-footer">
    <?php
    if ($item['status'] == 0) {
        ?>
        <input type="hidden" id="hiddenId" value="<?= $item['id'] ?>">
        <button class="btn btn-success" id="btnAuthOk">审核通过，提现成功</button>
        <button class="btn btn-danger" id="btnAuthFailed">审核失败</button>
        <?php
    }
    ?>
    <button class="btn btn-default" data-dismiss="modal">关闭</button>
</div>

<script type="application/javascript">
    (function () {

        $('#btnAuthOk').click(function () {
            var authId = $('#hiddenId').val();
            var authRemark = $('#authRemark').val().trim();
            requestJson('enchashment-auth-success-handler', {'id': authId, 'auth_remark': authRemark}, true, function (responseData) {
                if (responseData.status == 0) {
                    window.location.reload();
                } else if (responseData.status == 2) {
                    alert('审核失败。账户余额不足，不能提现。');
                } else {
                    alert('审核失败。');
                }
            })
        });

        $('#btnAuthFailed').click(function () {
            var authId = $('#hiddenId').val();
            var authRemark = $('#authRemark').val().trim();
            requestJson('enchashment-auth-failed-handler', {'id': authId, 'auth_remark': authRemark}, true, function (responseData) {
                if (responseData.status == 0) {
                    window.location.reload();
                }
            })
        });

    })(jQuery);
</script>
